package com.ym.b2b.provider.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ym.b2b.commons.controller.BaseController;
import com.ym.b2b.provider.service.EmBProviderProductService;
import com.ym.b2b.provider.sqlbean.EmBProviderProduct;
import com.ym.b2b.user.service.EmCUserService;
import com.zc.commons.base.Page;
import com.zc.commons.base.Result;

/**
 * @ClassName: EmCProviderController
 * @Description: TODO
 * @Author tangxj
 * @Date 2015-1-15 上午11:21:47
 * @Modify
 * @CopyRight B2B小组
 */
@Controller
@RequestMapping("/embproviderproduct")
public class EmBProviderProductController extends BaseController {

    @Autowired
    private EmBProviderProductService emBProviderProductService;
    @Autowired
    private EmCUserService            emCUserService;

    @RequestMapping("searchPageProviderProduct.do")
    @ResponseBody
    public Result searchPageProviderProduct(EmBProviderProduct emBProviderProduct, Page<EmBProviderProduct> page,
                                            HttpServletRequest req) {

        Result result = new Result();
        try {
            result = emBProviderProductService.searchPageEmBProviderProduct(page, emBProviderProduct);
        } catch (Exception e) {
            result.setCodeResult(Result.CODE_100, e.getMessage());
        }
        return result;

    }

    @RequestMapping(value = "insertProviderProduct.do")
    @ResponseBody
    public Result insertProviderProduct(EmBProviderProduct emBProviderProduct, HttpServletRequest req) {
        Result result = new Result();
        try {
            result = emBProviderProductService.insertProviderProduct(emBProviderProduct);
        } catch (Exception e) {
            result.setCodeResult(Result.CODE_100, e.getMessage());
        }
        return result;
    }

    // 删除一条记录
    @RequestMapping("deleteProviderProduct.do")
    @ResponseBody
    public Result deleteProvider(EmBProviderProduct emBProviderProduct, HttpServletRequest req) {
        Result result = new Result();
        try {
            result = emBProviderProductService.deleteEmBProviderProduct(emBProviderProduct);
        } catch (Exception e) {
            result.setCodeResult(Result.CODE_100, e.getMessage());
        }
        return result;
    }

    // 删除多条记录内容
    @RequestMapping("deleteMultipleEmBProviderProducts.do")
    @ResponseBody
    public Result deleteMultipleEmBProviderProducts(String providerProductIdList, HttpServletRequest req) {
        Result result = new Result();
        try {
            result = emBProviderProductService.deleteMultipleEmBProviderProducts(providerProductIdList);
        } catch (Exception e) {
            result.setCodeResult(Result.CODE_100, e.getMessage());
        }
        return result;
    }

}
